<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<body></body>
<script>
'use strict';
// From UseCounter.h
var AnimationSetPlaybackRateCompensatorySeek = 2162;
var MS_PER_SEC = 1000;
function createDiv() {
  var element = document.createElement('div');
  document.body.appendChild(element);
  return element;
}

var div = createDiv();
var animation = div.animate(null, 100 * MS_PER_SEC);
var startTimeBefore = animation.startTime;
animation.currentTime = 7 * MS_PER_SEC; // ms

promise_test(async t => {
  await animation.ready;

  assert_equals(animation.playState, "running");
  assert_not_equals(startTimeBefore, animation.startTime);

  assert_false(internals.isUseCounted(document, AnimationSetPlaybackRateCompensatorySeek));

  animation.playbackRate = 1.0;

  assert_false(internals.isUseCounted(document, AnimationSetPlaybackRateCompensatorySeek));

  animation.playbackRate = 0.5;

  assert_true(internals.isUseCounted(document, AnimationSetPlaybackRateCompensatorySeek));
}, 'Check to ensure that we UseCount when you cause a compensatory seek by setting playbackRate when playing');
</script>
